var oInp1=document.querySelector('.number');
var oInp2=document.querySelector('.nam');
var oInp3=document.querySelector('.age');
var oSpan1=document.querySelector('.span1');
var oSpan2=document.querySelector('.span2');
var oSpan3=document.querySelector('.span3');
var sub=document.querySelector('.sbm');

var num=0;

oInp1.onblur=function(){
    var str=oInp1.value;
    // console.log(str);
    var reg=/^[0-9a-zA-Z_]{6,20}$/;//就诊卡
    if(reg.test(str)){
        oSpan1.innerHTML='√';
        oSpan1.style.color='green';
        oInp1.value==''?num++:num=num;
        console.log(num);
    }else{
        oSpan1.innerHTML='✘';
        oSpan1.style.color='red';
    }
}

oInp2.onblur=function(){
    var str=oInp2.value;
    var reg=/^[\u4e00-\u9fa5]{2,6}$/;//姓名2-6个字
    if(reg.test(str)){
        oSpan2.innerHTML='√';
        oSpan2.style.color='green';
        num++;
        console.log(num);
    }else{
        oSpan2.innerHTML='✘';
        oSpan2.style.color='red';
    }
}

oInp3.onblur=function(){
    var str=this.value;
    var reg=/^([1-9]|[1-9]\d|1[0-9]\d)$/;//年龄;
    if(reg.test(str)){
        oSpan3.innerHTML='√';
        oSpan3.style.color='green';
        num++;
        console.log(num);
    }else{
        oSpan3.innerHTML='✘';
        oSpan3.style.color='red';
    }
}

sub.addEventListener('click', editStatus);
function editStatus() {
        if(num==3){
            $('#editStatus').modal('show');
            oInp1.value='';
            oInp2.value='';
            oInp3.value='';
            num=0;
            oSpan1.innerHTML='';
            oSpan2.innerHTML='';
            oSpan3.innerHTML='';
        }else{
            $('#eventTrace').modal('show');
            num=0;
        }
}


